<div class="box">
    <div class="heading">
        <h1><img alt="" src="<?php echo base_url('assets/admin/images/setting.png'); ?>"> News Feed Setting</h1>
		<div class="buttons">
            <a href="javascript:void(0);" class="button" onclick="$('#form').submit();"><span>Save</span></a>
            <a href="" class="button"><span>Cancel</span></a>
        </div>		
    </div>
    <div class="content">
		<?php echo form_open(null, 'id="form"'); ?>
        <table id="newsfeed_table" class="list">
            <thead>
                <tr>
                    <th>News Name</th>
                    <th>News Url</th>
					<th>News Status</th>
                    <th class="right">Action</th>
					
                </tr>
            </thead>
            <?php $row = 0; ?>
            <?php foreach($allnewsfeed as $newsfeed){ ?>
                <tbody id="row<?php echo $row; ?>">
					<tr>
                        <td><input type="text" value="<?=$newsfeed['news_name']?>" name="zap_newsfeed[<?php echo $row; ?>][news_name]" /></td>
						<td><input type="text" value="<?=$newsfeed['news_url']?>" name="zap_newsfeed[<?php echo $row; ?>][news_url]" /></td>
						<td>
						<select name="zap_newsfeed[<?php echo $row; ?>][news_status]">
							<option value="1" <?php if($newsfeed['news_status']==1) echo "selected='selected'"?>>Enable</option>
							<option value="0" <?php if($newsfeed['news_status']==0) echo "selected='selected'"?>>Disable</option>
						</select>
						<td class="right"><a onclick="$('#row<?php echo $row; ?>').remove();" class="button">Remove</a></td>
                    </tr>
				</tbody>
			<?php $row++; ?>
            <?php } ?>
			<tfoot>
            <tr>
              <td colspan="3"></td>
              <td class="right"><a onclick="addrow();" class="button">Add URL</a></td>
            </tr>
          </tfoot>
        </table>
		
        <?php echo form_close(); ?>
        
    </div>
</div>
<script type="text/javascript"><!--
var row = <?php echo $row; ?>;

function addrow() {	
	html  = '<tbody id="row' + row + '">';
	html += '  <tr>';
	html += '    <td><input type="text" name="zap_newsfeed[' + row + '][news_name]"></td>';
	html += '    <td><input type="text" name="zap_newsfeed[' + row + '][news_url]"/></td>';
	html += '    <td><select name="zap_newsfeed[' + row + '][news_status]">';
    html += '      <option value="1" selected="selected">Enable</option>';
    html += '      <option value="0">Disable</option>';
    html += '    </select></td>';
	html += '    <td class="right"><a onclick="$(\'#row' + row + '\').remove();" class="button">Remove</a></td>';
	html += '  </tr>';
	html += '</tbody>';
	
	$('#newsfeed_table tfoot').before(html);
	
	row++;
}
//--></script>
